/******************************************/
/************* GPStrac Server *************/
/******************************************/
/*
* FILE: gpsServer.h
* AUTHOR: Ram Subramanian and Nicolas Papin
* PROJECT: CS 3251 Project 2 - Professor Traynor
* DESCRIPTION: Application server header.
* PURPOSE: Defines some elements used by the server exclusively.
*/

#ifndef _GPS_SERVER_H
#define _GPS_SERVER_H

#include "list.h"

//
// DEFINITIONS
//
#define MAX_PENDING 5
#define MAX_CONNECTED 20

#define SAVE_STR_LEN 10
#define SAVE_STR "data/%s.usr"

//
// USER LIST
//
userList_t *users;
pthread_mutex_t userListMut;
pthread_cond_t userListCond;


//
// FILE THREAD SAFETY
//
pthread_mutex_t fileMutex;


//
// PROGRAM EXIT
//
int exitFlg = 0;


//
// FUNCTION DECLARATIONS
//
void *serveClient(void *socket);
void getUserID(userNode_t *userNode);
void processRequests(userNode_t *userNode);

void updateRequest(userNode_t *userNode, clntReq_t *request);
void viewRequest(userNode_t *userNode, clntReq_t *request);
void histRequest(userNode_t *userNode, clntReq_t *request);

void defaultRecieve(userNode_t *node, void *outBuffer, size_t amount);
void defaultSend(userNode_t *node, const void *data, size_t amount);
void terminateConnection(userNode_t *node, char *msg);

#endif
